import java.util.Scanner;

public class SimulatedLogin {
    public static void main(String[] args) {
        System.out.println("请输入密码");
        String code = "123456";
        int chance = 2;
        while (chance != 0) {
            Scanner in = new Scanner(System.in);
            String input = in.nextLine();
            if (input.equals(code)) {
                System.out.println("登陆成功!");
                break;
            }
            else {
                System.out.println("密码错误!剩余 " + chance + " 次机会");
                chance--;
            }
        }
    }
}
